<html>
<head><meta charset="utf-8"><title>Unresolved import diagnostics and incrementality · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html">Unresolved import diagnostics and incrementality</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217893062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217893062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217893062">(Nov 25 2020 at 14:44)</a>:</h4>
<p>I'm trying to make the <code>typing_inside_a_function_should_not_invalidate_def_map</code> test fail by putting an unresolved import at the end of <code>lib.rs</code>, but it's still passing.</p>
<p>Since that diagnostic contains a <code>SyntaxNodePtr</code>, I would expect that to fail though. Does anyone know what's going on?</p>



<a name="217908751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217908751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217908751">(Nov 25 2020 at 16:39)</a>:</h4>
<p>Related issue: I'm trying to make name resolution collect and report errors from macro expansion, but this makes incrementality worse, since every macro call in item position now recomputes the CrateDefMap when changed (since the errors might have changed).</p>



<a name="217908785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217908785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217908785">(Nov 25 2020 at 16:39)</a>:</h4>
<p>Not sure if that's a big issue, but it seems unfortunate</p>



<a name="217910485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217910485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217910485">(Nov 25 2020 at 16:52)</a>:</h4>
<p>not sure I understand the problem -- before that, changing the macro call might already have changed the items, which would also require a CrateDefMap recalculation, so what's different?</p>



<a name="217910891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217910891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217910891">(Nov 25 2020 at 16:55)</a>:</h4>
<blockquote>
<p>Since that diagnostic contains a SyntaxNodePtr, I would expect that to fail though. Does anyone know what's going on?</p>
</blockquote>
<p>the actual diagnostic returned by the query contains a <code>FileAstId</code>, not a <code>SyntaxNodePtr</code>, which is an index that doesn't change that easily. I think at least that's the answer</p>



<a name="217910993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217910993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217910993">(Nov 25 2020 at 16:56)</a>:</h4>
<p>it gets turned into a SyntaxNodePtr while collecting diagnostics later</p>



<a name="217911090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217911090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217911090">(Nov 25 2020 at 16:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Unresolved.20import.20diagnostics.20and.20incrementality/near/217910485">said</a>:</p>
<blockquote>
<p>not sure I understand the problem -- before that, changing the macro call might already have changed the items, which would also require a CrateDefMap recalculation, so what's different?</p>
</blockquote>
<p>Previously nameres only fetched the item tree, which doesn't necessarily change if the macro change only affects item bodies</p>



<a name="217911334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217911334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217911334">(Nov 25 2020 at 16:58)</a>:</h4>
<p>The <code>CrateDefMap</code> stores a list of <code>DefDiagnostic</code>s, which contains <code>SyntaxNodePtr</code>s for the <code>UnconfiguredCode</code> case here: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/9b512f8569dda32fe2d12114adeed2f612d0190f/crates/hir_def/src/nameres.rs#L303">https://github.com/rust-analyzer/rust-analyzer/blob/9b512f8569dda32fe2d12114adeed2f612d0190f/crates/hir_def/src/nameres.rs#L303</a></p>



<a name="217911461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217911461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217911461">(Nov 25 2020 at 16:59)</a>:</h4>
<p>ok, that might be bad? maybe it should be an <code>AstId</code>, like for the other diagnostics</p>



<a name="217911570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217911570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217911570">(Nov 25 2020 at 17:00)</a>:</h4>
<p>but you were talking about <code>UnresolvedImport</code> in the beginning, right?</p>



<a name="217911649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217911649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217911649">(Nov 25 2020 at 17:00)</a>:</h4>
<p>Oh, right, sorry</p>



<a name="217911670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217911670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217911670">(Nov 25 2020 at 17:00)</a>:</h4>
<p>I meant only <code>UnconfiguredCode</code></p>



<a name="217911690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217911690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217911690">(Nov 25 2020 at 17:00)</a>:</h4>
<p>So that explains why I haven't been able to trigger this :D</p>



<a name="217911994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217911994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217911994">(Nov 25 2020 at 17:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211727">Jonas Schievink</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Unresolved.20import.20diagnostics.20and.20incrementality/near/217911090">said</a>:</p>
<blockquote>
<p>Previously nameres only fetched the item tree, which doesn't necessarily change if the macro change only affects item bodies</p>
</blockquote>
<p>ok. If it now just fetches the item tree + errors, that shouldn't have much of an effect on incrementality, right? Only if errors actually change.</p>
<p>It might be possible to collect the errors completely separately though (i.e. nameres uses a projection query that just gets the item tree, without errors, and there's a separate query that collects all the errors from macro expansions. the complicated part would be knowing which macro expansions to query)</p>



<a name="217912363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217912363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217912363">(Nov 25 2020 at 17:05)</a>:</h4>
<p>If it now fetches the whole expansion + errors, that would be a problem, and there should probably be a query that turns that into item tree + errors</p>



<a name="217912540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217912540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217912540">(Nov 25 2020 at 17:06)</a>:</h4>
<p>hmm, yeah, that sounds like it should work</p>



<a name="217912562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/217912562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#217912562">(Nov 25 2020 at 17:06)</a>:</h4>
<p>thanks!</p>



<a name="218032172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/218032172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#218032172">(Nov 26 2020 at 19:16)</a>:</h4>
<p>I ended up going with a simpler firewall query that turns the macro expansion result into just the expansion error <a href="https://github.com/rust-analyzer/rust-analyzer/pull/6645">https://github.com/rust-analyzer/rust-analyzer/pull/6645</a></p>



<a name="218032510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Unresolved%20import%20diagnostics%20and%20incrementality/near/218032510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Unresolved.20import.20diagnostics.20and.20incrementality.html#218032510">(Nov 26 2020 at 19:22)</a>:</h4>
<p>ah yeah, there's no need to combine the two</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>